package com.work.demo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@Configuration
public class DatabaseConfig {
    @Value("${spring.datasource.primary.jdbcUrl:jdbc:mysql://10.8.2.16:3308/dev-jf-gw1027-n1_sd_node?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false}")
    private  String url;

    @Value("${spring.datasource.primary.username:dev-jf-gw1027}")
    private  String name;

    @Value("${spring.datasource.primary.password:Single&2020}")
    private  String password;

    @Bean
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setUrl(url);
        dataSource.setUsername(name);
        dataSource.setPassword(password);
        return dataSource;
    }
}
